import instance from "../../utils/axios";

//获取用户频道列表
function gitList() {
    return  instance ({
        url: "/v1_0/channels",
        method:'get',
    })
}
function getArticles({channel_id,timestamp}){
    return instance({
        url: '/v1_1/articles',
        method: 'get',
        params: {
            channel_id:0,
            timestamp,
            with_top:1
        }
    })
}
//获取新闻文章详情
function newArticle(id) {
    return  instance ({
        url:'/v1_0/articles/' + id,
        method:'get',
    })
}
//4.关注用户
const getguan =target => {
    return instance({
      url: '/v1_0/user/followings',
      method:'post',
      data:target
    })
  }
  
  //5.取消用户
  const ungetguan = ( target ) => {
    return instance({
      //这个接口的id直接在路径后面拼接  格式： url/target
      url: '/v1_0/user/followings/' + target,
      method:'delete',
    })
  }
// 点赞
const givtLike =({target}) => {
    return instance({
        url: '/v1_0/article/likings',
        method: 'post',
        data:{target}
    })
}
// 取消点赞
const cancelLike = (target)=> {
    return instance({
        url:`/v1_0/article/likings/${target}`,
        method:'delete'
    })
}
//取消对文章不喜欢
const xihuan = (target ) => {
    return instance({
        url: `/v1_0/article/dislikes/${target}`,
        method: 'delete'
    })
}
//对文章不喜欢
const buxihuan = ({ target }) => {
    return instance({
        url: '/v1_0/article/dislikes',
        method: 'post',
        data:{target}
    })
}
//获取联想关键词
function  getKeywords(q){
    return instance({
        url: '/v1_0/suggestion',
        method: 'get',
        params:q
    })
}

//导出接口
export {gitList,getArticles,newArticle,getguan,ungetguan,givtLike,cancelLike,xihuan,buxihuan,getKeywords}